package com.qifan.energy.util;

import androidx.annotation.Keep;

//import wendu.dsbridge.CompletionHandler;

@Keep
public class JsApi {

    /*private Activity activity;

    public JsApi(Activity activity) {
        this.activity = activity;
    }

    //同步API
    @JavascriptInterface
    public String testSyn(Object msg) {
        return msg + "［syn call］";
    }

    //异步API
    @JavascriptInterface
    public void testAsyn(Object msg, CompletionHandler<String> handler) {
        handler.complete(msg + " [ asyn call]");
    }

    @JavascriptInterface
    public void getUserId(Object msg, final CompletionHandler<String> handler) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.putOpt("userId", "UserInfoUtil.getUserInfo().getId()");
            jsonObject.putOpt("isAuthorize", "UserInfoUtil.getUserInfo().getIsAuthorize()");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        handler.complete(jsonObject.toString());
    }

    @JavascriptInterface
    public Object setSyncForTaoke(Object msg) {
        boolean isSyncForTaoke = Boolean.valueOf(msg.toString());
        //return AlibcTradeSDK.setSyncForTaoke(isSyncForTaoke);
        return false;
    }

    @JavascriptInterface
    public void setChannel(Object msg) {
        //String typeName, String channelName
        try {
            JSONObject jsonObject = (JSONObject) msg;
            String typeName = jsonObject.optString("type", "0");
            String channelName = jsonObject.optString("channel", null);
            //AlibcTradeSDK.setChannel(typeName, channelName);
        } catch (Exception e) {
            Toast.makeText(activity.getApplicationContext(), "设置错误:" + e.getMessage(), Toast.LENGTH_LONG).show();
        }
    }*/
}
